<template>
<!-- vue3组件中的模板结构可以没有根标签 -->
  <h1>姓名：{{name}}</h1>
  <h2>年龄：{{age}}</h2>
  <h3>工作：{{job.type}}</h3>
  <h4>薪水：{{job.salary}}</h4>
  <button @click="changeInfo">修改信息</button>
</template>

<script>
import { reactive, ref } from '@vue/reactivity'
  export default {
    name: 'App',
    setup(){
      //数据
      let name = ref('张三')
      let age = ref(18)
      let job = ref({
        type: 'java工程师',
        salary: '4.5k'
      })

      // let number = reactive('678')

      //方法
      function changeInfo() {
        name.value = '李四'
        age.value = 20
        job.value.type = 'java中级工程师'
        job.value.salary = '16k'
      }

      //返回一个对象
      return {
        name,
        age,
        job,
        changeInfo
      }
    }
  }
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
